package data;

import jmetal.core.Solution;
import jmetal.encodings.variable.ArrayReal;
import jmetal.util.JMException;

public class Example{

	private double[] inputs;
	private double[] outputs;

	public Example(Solution s) throws JMException {
		this.inputs = new double[s.getNumberOfObjectives()];
		this.outputs = new double[s.getProblem().getNumberOfVariables()];
		init(s);
	}

	private void init(Solution s) throws JMException {

		int numInputs = s.getNumberOfObjectives();
    	double valueCurrent = 0;
    	
    	//add inputs
    	for(int z = 0; z < numInputs ; z++)
		{
			valueCurrent = s.getObjective(z);
			inputs[z] = valueCurrent;
		}

    	//add outputs -- index 0 because receipted variables other types
		ArrayReal variables = (ArrayReal) s.getDecisionVariables()[0];
		for (int z = 0; z < variables.getLength(); z++) {
			valueCurrent = variables.getValue(z);
			outputs[z] = valueCurrent;
		}
	}
	
	public double[] getInputs()
	{
		return inputs;
	}
	
	public double[] getOutputs()
	{
		return outputs;
	}
	
	public void setInputs(double[] in)
	{
		this.inputs = in;
	}
	
	public void setOutputs(double[] out)
	{
		this.outputs = out;
	}

}
